<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ag.lzw.action.*"%>
<%@page import="com.ag.lzw.vo.*"%>
<%@page import="com.ag.bean.*" %>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'plan_tree.jsp' starting page</title>
		<link href="css/jquery.treeview.css" rel="stylesheet" type="text/css" />
<%--		<link href="lzm/css/base.css" rel="stylesheet" type="text/css" />--%>
		<script src="/ag/js/jquery-1.4.2.min.js" type="text/javascript"></script>
		<script src="/ag/js/jquery.treeview.js" type="text/javascript"></script>
        <script src="/ag/lzw/js/task_tree.js" type="text/javascript"></script>
        <script type="text/javascript" src="/ag/lzw/js/jquery.cookie.js"></script>

		<style type="text/css"><!--
.pcol {
	cursor: pointer;
	color: #960;
}

.pcoc {
	display: none;
}

.pcol:hover {
	font-size: 18px;
	color: red;
	text-decoration: underline;
}

body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	padding: 0px;
}

#loading {
	width: 100%;
	height: 50px;
	position: absolute;
	top: 50%;
	left: 0;
	margin: -25px 0 0 0;
	text-align: center;
}

.secondmenuClick {
	cursor: pointer;
	padding-left:10px;
	text-align: left;
	font-weight: bold;
	font-size:14px;
	color: #633;
}

-->
</style>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		
	</head>

	<body style="background-color: rgb(220, 239, 253);">
	
	<%!
	public void printTree(TaskTreeVo treeNode, JspWriter out, int level) throws Exception {
		if(treeNode!=null){
		    TbTask node=treeNode.getNode();
		    if(node!=null){
		    
		    	System.out.print("\n---node.getTName():"+node.getTName());
				
		    	out.println("<li style='background-color: rgb(220, 239, 253);'><span class='deptclick' value='"+
		    			node.getTId().toString()+"'>" + 
		    			node.getTName().toString()+
		    			"("+node.getTbUserDept().getUdName()+")"+
		    			"</span>");
		    	out.println("<ul style='background-color: rgb(220, 239, 253);'><li class='secondmenuClick'>"+
		    	            "<img src='images/secondmenuhead.png'/>"+
		    	            "<a href='javascript:;' class='eventDetail' value='"+node.getTId().toString()+"'>事件详情</a></li>");
		    	
		    	out.println("<li style='background-color: rgb(220, 239, 253);' class='secondmenuClick'>"+
		    	            "<img src='images/secondmenuhead.png'/>"+
		    	            "<a href='javascript:;' class='taskDetail' value='"+node.getTId().toString()+"'>任务详情</a></li>");
		    	
		    	out.println("<li style='background-color: rgb(220, 239, 253);' class='secondmenuClick'>"+
	    	            "<img src='images/secondmenuhead.png'/>"+
	    	            "<a href='javascript:;' class='taskfeedback' value='"+node.getTId().toString()+"'>任务反馈</a></li>");
		    	
		    	out.println("<li style='background-color: rgb(220, 239, 253);' class='secondmenuClick'>"+
				            "<img src='images/secondmenuhead.png'/>"+
				            "<a href='javascript:;' class='taskOver' value='"+node.getTId().toString()+"'>任务办结</a></li>");
		    	
		    	if(level<2){
			    	out.println("<a href='javascript:;' class='newtask' value='"+node.getTId().toString()+"' style='display:none;'></a>");
			    	
			    	out.println("<li style='background-color: rgb(220, 239, 253);' class='secondmenuClick' style='display:none;'>"+
		    	            "<a href='javascript:;' class='addtaskfeedback' value='"+node.getTId().toString()+"' style='display:none;'></a></li>");
		    	}
			       		
				//<a>标签在<ul>标签前代表是父节点，<ul>是打开开关，<li>是子节点
				Set<TaskTreeVo> childNode = treeNode.getChildrenNode();
				
				if(childNode!=null){
					out.println("<li style='background-color: rgb(220, 239, 253);' class='secondmenuClick'>"+
				            "<img src='images/secondmenuhead.png'/>"+
				            "<a href='javascript:;' class='subTask' value='"+node.getTId().toString()+"'>子任务</a><ul>");	
					for(TaskTreeVo ttv : childNode){
						printTree(ttv,out,++level);
					}
					out.println("</ul></li>");
				} 
				out.println("</ul>");
				return ;
						
		    } else {
				return ;
		    }
		} else {
			return ;
		}
	}
	%>
	
	      <div id="loadDIV" style="background-color: rgb(220, 239, 253);">
			<ul id="navigation" style="background-color: rgb(220, 239, 253);">
				<li style="background-color: rgb(220, 239, 253);">
				<div>
				<a href="javascript:;">当前任务</a>&nbsp;
				<input type="button" name="addtask" id="bt_addtask" value="新增任务">&nbsp;
				<input type="button" name="addfeedback" id="bt_addfeeback" value="添加反馈">
				</div>
					<ul id="Tree" style="background-color: rgb(220, 239, 253);">
               <%   
				Object treeObj = request.getAttribute("tree");
                TaskTreeVo tasktree = (TaskTreeVo)treeObj;
				printTree(tasktree,out,1);
			   %>	
					</ul>
				</li>
			</ul>
		</div>

	</body>
</html>
